//
//  DateTabHeader.m
//  TenMinDemo
//
//  Created by Shawn Li on 2021/3/8.
//  Copyright © 2021 CYXiang. All rights reserved.
//

#import "DateTabHeader.h"

@interface DateTabHeader ()
@property (weak, nonatomic) IBOutlet UIView *bgView;

@end

@implementation DateTabHeader

- (void)awakeFromNib{
    [super awakeFromNib];
    
    CGRect frame = self.bgView.bounds;
    frame.size.width = SCREEN_WIDTH - 30;
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: frame byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10,10)];
      //创建 layer
      CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
      maskLayer.frame = frame;
      //赋值
      maskLayer.path = maskPath.CGPath;
    self.bgView.layer.mask = maskLayer;
  
}

- (void)refresh{
    if (self.isRadius) {
        CGRect frame = self.bgView.bounds;
        frame.size.width = SCREEN_WIDTH - 30;
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: frame byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10,10)];
          //创建 layer
          CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
          maskLayer.frame = frame;
          //赋值
          maskLayer.path = maskPath.CGPath;
        self.bgView.layer.mask = maskLayer;
    }else{
        self.bgView.layer.mask = nil;
    }
}


@end
